package com.flection.summer.loadbalance;

import java.util.List;
import org.springframework.util.CollectionUtils;
import com.netflix.loadbalancer.Server;

/**
 * 
 * @author thnl
 *
 * @param <T>
 */
public abstract class AbstractRandomLoadBalance<T> implements RouteRandomLoadBalance<T> {
	@Override
	public Server choose(List<Server> serverList) {
		if (CollectionUtils.isEmpty(serverList)) {
			return null;
		}

		RouteRandom<Server> routeRandom = new RouteRandom<Server>(serverList);

		return routeRandom.random();
	}
}